package com.hhs.storage.bean;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.hhs.storage.util.SysUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 *
 * </p>
 *
 * @author hhs
 * @since 2022-12-21
 */
@Data
public class Car implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 空闲
     */
    public static final Integer STATE_FREE = 0;
    /**
     * 占用
     */
    public static final Integer STATE_WORK = 1;
    /**
     * 异常
     */
    public static final Integer STATE_ERROR = 2;

    private String id;

    /**
     * 车牌
     */
    private String licencePlate;

    /**
     * 所属车队id
     */
    private String carFleetId;
    @TableField(exist = false)
    private CarFleet carFleet;
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 载重量
     */
    private BigDecimal loadCapacity;
    private Integer state;
    private String phone;
    @TableField(exist = false)//出车次数
    private Integer workTimes;
    @TableField(exist = false)//异常次数
    private Integer errorTimes;
    public String getStateName(){
        return SysUtil.CAR_STATE_MAP.get(this.state);
    }
}
